//
//  ListTableViewCell.m
//  HimalayaMusic
//
//  Created by dllo on 16/1/6.
//  Copyright © 2016年 WXCLegendary. All rights reserved.
//

#import "ListTableViewCell.h"

@implementation ListTableViewCell


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        

        self.titleLabel = [[UILabel alloc] init];

        self.imageViews = [[UIImageView alloc] init];

        self.firstLabel = [[UILabel alloc] init];

        self.secondLabel = [[UILabel alloc] init];

        [self addSubview:self.titleLabel];
        [self addSubview:self.imageViews];
        [self addSubview:self.firstLabel];
        [self addSubview:self.secondLabel];
        
    }
    return self;
}

-(void)layoutSubviews {
    [super layoutSubviews];
    self.imageViews.frame = CGRectMake(10, 5, self.height - 10, self.height - 10);
    self.titleLabel.frame = CGRectMake(self.imageViews.width + 15, 10, self.width - self.imageViews.width - 20, (self.height - 20)/ 3);
    self.titleLabel.font = [UIFont systemFontOfSize:14];
    self.firstLabel.frame = CGRectMake(self.imageViews.width + 15, 10 + self.titleLabel.height, self.titleLabel.width, (self.height - 20)/ 3);
    self.firstLabel.font = [UIFont systemFontOfSize:12];
    self.firstLabel.textColor = [UIColor grayColor];
    self.secondLabel.frame = CGRectMake(self.imageViews.width + 15, 10 + self.titleLabel.height + self.firstLabel.height, self.titleLabel.width, (self.height - 20)/ 3);
    self.secondLabel.font = [UIFont systemFontOfSize:12];
    self.secondLabel.textColor = [UIColor grayColor];
}

-(void)setListModel:(ListModel *)listModel {
    if (_listModel != listModel) {
        _listModel = listModel;
    }
    
    self.titleLabel.text = self.listModel.title;
    [self.imageViews sd_setImageWithURL:[NSURL URLWithString:self.listModel.coverPath]];
    self.firstLabel.text = [[self.listModel.firstKResults firstObject] objectForKey:@"title"];
    self.secondLabel.text = [[self.listModel.firstKResults lastObject] objectForKey:@"title"];
    
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
